#ifndef COCOSITEMLIST_H_20120229
#define COCOSITEMLIST_H_20120229

#include "CocosUIContainer.h"

class CCocosItem : public CCocosUIContainer
{
public:
	LAYER_NODE_FUNC(CCocosItem);
	virtual void onCurTouchFinish();
public:

	static CCocosItem *CreateItem(const char *szBackName, bool bUseFrame = false);
private:
	

};


class CCocosItemList : public CCocosUIBase 
{
public:
	static CCocosItemList *CreateItemList(const cocos2d::CCRect &rect);
	
	virtual void onReceiveNewTouch();
	virtual void onCurTouchMoving();
	virtual bool isContainsTouch(cocos2d::CCTouch *pTouch);
	LAYER_NODE_FUNC(CCocosItemList);

	CCocosItemList(void);
	~CCocosItemList(void);

	void SetEnable(bool bEnable);
		
	void ResortItems();

	void AddItem(CCocosItem *pItem);
	void InsertItem(CCocosItem *pItem, unsigned int pos);
	bool ChangeItem(CCocosItem *pItem, unsigned int pos);

	void BeginUpdate();

	
	
private:
	void InitState(const cocos2d::CCRect &rect);
	void OnUpdateItems(cocos2d::ccTime dt);
private:
	cocos2d::CCRect m_rc;
	ListItem  m_listItems;
	QueueItem m_qRemovedItems;
	float    m_lastY;
	float    m_startY;
	float    m_curSpeed;
	float    m_listHeight;
	bool     m_bMoving;

};


#endif